const app = getApp()
import BaseModel from '../../utils/common.js'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:"",
    page:1,
    size:6, //每页条数
    enrollMesData:"",
    footer_more:"没有更多数据了",
    empty_title:"",
    empty_img:"",
    empty_again:"",//重试
    is_clickTab:0 //重试或下拉是0，上啦是1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
      this.setData({
        id:options.id
      })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getEnrollMesData(); //已报人员
  },

  /*已报人员*/
  getEnrollMesModel: new BaseModel({
    url: 'registeredActivity',
    method: "get",
    needAjaxLoading:true,
    loadingText:"玩命加载中"
  }),
  getEnrollMesData() {
    this.getEnrollMesModel
        .fetch({
          "activityId":this.data.id
        })
        .then(res => {
          if(res.data==""||res.data==null){
            this.setData({
                empty_title:"暂无数据",
                empty_img:"http://hwj2018.oss-cn-beijing.aliyuncs.com/hwj2019/icon_new3.0/empty_mes.png",
                empty_again:"",//重试
            })
          }
          this.setData({
            enrollMesData: res.data
          })
        })
        .catch(res => {
          //失败
          this.setData({
            empty_title:"请求失败",
            empty_img:"http://hwj2018.oss-cn-beijing.aliyuncs.com/hwj2019/icon/empty_data.png",
            empty_again:"重试",//重试
          })
        })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  //重试
  again_request:function(){
    /*this.setData({
      is_clickTab:0,
      page:1
    })*/
    this.getEnrollMesData();
  },
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    /*this.setData({
      is_clickTab:0,
      page:1
    })*/
    this.getEnrollMesData();
    wx.stopPullDownRefresh(); //停止下拉
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    /*var that = this;
    that.data.page+=1;
    this.setData({
      is_clickTab:1  //上拉加载标识
    })
    this.getlinedownAllData();*/
  },

})